import request from '@/utils/request'

export interface ActivityDTO {
  activityId?: string
  activityType: 'VISIT' | 'CALL' | 'EMAIL' | 'MEETING' | 'OTHER'
  activityName: string
  customerId?: string
  contactId?: string
  opportunityId?: string
  ownerUserId?: string
  activityDate: string
  duration?: number
  location?: string
  description?: string
  result?: string
  nextFollowDate?: string
  status?: 'PLANNED' | 'COMPLETED' | 'CANCELLED'
  remark?: string
}

// 销售活动管理API
export function pageActivity(params: {
  pageNum: number
  pageSize: number
  activityName?: string
  activityType?: string
  customerId?: string
  contactId?: string
  opportunityId?: string
  ownerUserId?: string
  status?: string
  startTime?: string
  endTime?: string
}) {
  return request({ url: '/crm/activity/page', method: 'get', params })
}

export function getActivity(id: string) {
  return request({ url: `/crm/activity/${id}`, method: 'get' })
}

export function createActivity(data: ActivityDTO) {
  return request({ url: '/crm/activity', method: 'post', data })
}

export function updateActivity(id: string, data: ActivityDTO) {
  return request({ url: `/crm/activity/${String(id)}`, method: 'put', data })
}

export function deleteActivity(id: string) {
  return request({ url: `/crm/activity/${String(id)}`, method: 'delete' })
}

export function deleteActivityBatch(ids: string[]) {
  return request({ url: '/crm/activity/batch-delete', method: 'post', data: ids })
}


